package cn.itcast.order.client.fallback;

import cn.itcast.order.client.UserClient;
import cn.itcast.order.pojo.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Copyright (C), 2022-2022, 姚兵
 * Author: 32210
 * Date: 2022/10/6 23:45
 * FileName: UserClientFallbackFactory
 * Description:
 */


//降级规则
@Component
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        log.error("被降级");
        return new UserClient() {
            @Override
            public User queryById(Long id) {
                log.error("被降级返回空的用户对象");
                return new User();
            }
        };
    }
}
